//
//  BJArticleCommentTableViewCell.m
//  BowJoy
//
//  Created by  on 2024/5/22.
//

#import "BJArticleCommentTableViewCell.h"


@implementation BJArticleCommentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.voicePlayer = [[SVGAPlayer alloc] init];
   [self.voiceBaView addSubview:self.voicePlayer];
    self.voicePlayer.makeCons(^{
        make.centerY.constants(0);
        make.left.constants(5);
        make.width.constants(20);
        make.height.constants(20);
    });
    self.parser = [[SVGAParser alloc]init];
    [self.parser parseWithNamed:@"voicePlay_left" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
    if(videoItem !=nil) {
          self.voicePlayer.videoItem= videoItem;
//        [self.voicePlayer startAnimation];
        }
    }failureBlock:^(NSError*_Nonnullerror) {

    }];
    
    // Initialization code
}


- (void)setModel:(BJAnchorWallModelData *)model{
    
    self.followNumL.text = [NSString stringWithFormat:@"%ld",model.followNum];
    self.follewIcon.image = model.isFriend ? [UIImage imageNamed:@"icon_love_red"]:[UIImage imageNamed:@"icon_love_gray"];
    self.nikeNameL.text = [BJUserManager sharedManager].userInfoData.nickname;
    [self.headerIcon setImageURL:[NSURL URLWithString:[BJUserManager sharedManager].userInfoData.avatarUrl]];
    NSString *iconPictureFrame =  [[NSUserDefaults standardUserDefaults] objectForKey:KSelectPictureFrameKey];
    if (iconPictureFrame) {
        self.headerBgIcon.hidden = NO;
        self.headerBgIcon.image = [UIImage imageNamed:iconPictureFrame];
    }else{
        self.headerBgIcon.hidden = YES;

    }

    
    if (model.isVoice) {
        self.voiceBaView.hidden = NO;
        self.commetL.hidden = YES;
        self.voiceTime.text = [NSString stringWithFormat:@"%lds",(long)model.voiceTime];
    }else{
        self.voiceBaView.hidden = YES;
        self.commetL.hidden = NO;
        self.commetL.text = model.voiceFileName;

    }
    
    if (model.isOpenVoice) {
        [self.voicePlayer startAnimation];
        self.voiceLabaIcom.hidden = YES;
    }else{
        [self.voicePlayer stopAnimation];
        self.voiceLabaIcom.hidden = NO;
    }

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
